package com.example.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.pojo.MsslyyBook;
import com.example.pojo.MsslyyFootprint;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.mapper.MsslyyFootprintMapper;
import com.example.pojo.MsslyyWishlist;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class MsslyyFootprintService extends ServiceImpl<MsslyyFootprintMapper, MsslyyFootprint> {

    @Resource
    private MsslyyFootprintMapper msslyyFootprintMapper;
    @Resource
    private MsslyyBookService msslyyBookService;
    public List getFootprintById(Long id){
        QueryWrapper<MsslyyFootprint> queryWrapper=new QueryWrapper<>();
        LambdaQueryWrapper<MsslyyFootprint> eq = queryWrapper.lambda().eq(MsslyyFootprint::getUserId, id);
        List<MsslyyFootprint> list = list(eq);
        List<MsslyyBook> books = msslyyBookService.list();
        List books2 =new ArrayList();
        books.forEach(e->{
            list.forEach(b->{
                if (e.getId()==b.getBookId()){
                    e.setAddTime(b.getCreateTime());
                    books2.add(e);
                }
            });
        });

        return books2;
    }

}
